/*
运算符重载 拔高题
1.编写程序实现两个整数集合的基本运算：
S1+S2 集合并运算
S1-S2 集合差运算
S1*S2 集合交运算
	【实验要求】
	输入整数集合{2 4 1 3 5}和{2 5 10}，输出前者元素个数以及它们进行集合并、差、交运算后的结果。
*/
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

#define MAXSIZE 100

class Set {
	private:
		int set[MAXSIZE];
		int oneLen;

	public:
		Set() {
			cout << "Constructing..." << endl;
			memset(set, 0, sizeof(set));
			oneLen = MAXSIZE;
		}
		~Set() {
			cout << "Deconstructing..." << endl;
		}

		Set operator + (const Set &);
		Set operator - (const Set &);
		Set operator * (const Set &);

		friend istream & operator >> (istream & stream, Set & obj);
		friend ostream & operator << (ostream & stream, const Set & obj)
};

bool b_in_a(int a[], int b) {
	for(int i=0; a[i]; i++)
		if(b == a[i])
			return false;
	return true;
}

Set Set::operator + (const Set & obj) {
	int temp[MAXSIZE];
	for(int i=0; set[i]; i++) {
		temp[i] = set[i];
	}
	// Element One Length
	oneLen = i;

	for(int j=0; obj.set[j]; j++) {
		if(! b_in_a(set, obj.set[j]))
			temp[i++] = obj.set[j];
	}

	return temp;
}

Set Set::operator - (const Set & obj) {
	int temp[MAXSIZE];
	for(int i=0; set[i]; i++) {
		temp[i] = set[i];
	}
	// Element One Length
	oneLen = i;
	int t = oneLen;

	for(int j=0; obj.set[j]; j++) {
		for(int i=0; i<oneLen; i++) {
			if(obj.set[j] == temp[i]) {
				temp[i] = 0;
					
			}
		}
	}

	return temp;
}

istream & operator >> (istream & stream, Set & obj) {
	
}

int main(int argc, char * argv[]) {
		

	return 0;
}
